home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 2614.ZIP / 50ERRS.ZIP / S87DEMO.PRG next >
Text File  |  1990-10-05  |  4KB  |  151 lines

  1. /**************************************************************************
  2. *
  3. * Module name:
  4. *
  5. *    S87Demo.PRG
  6. *
  7. * What it does:
  8. *
  9. *    This program allows you to generate an error for each of the
  10. *    six (6) error UDF()s in the Summer '87 ErrorSys.PRG.  It is
  11. *    useful in demonstrating how to use the S87ErMap() routine that
  12. *    re-packages Clipper 5.0 Error Handling conventions to those 
  13. *    compatible with Summer '87.
  14. *
  15. * How to compile it:
  16. *
  17. *    Clipper S87Demo
  18. *
  19. * How to link it:
  20. *
  21. *    RTLINK fi S87Demo,S87ErMap,S87ErSys out S87Demo
  22. *
  23. *    Note:  S87ErSys.PRG is a copy of Summer '87 stock ErrorSys.PRG.
  24. *    It is included in this distribution as a convenience.  It
  25. *    is renamed S87ErSys.PRG in order not to conflict with your
  26. *    own copy of ErrorSys.PRG in the same subdirectory.
  27. *
  28. * To request Summer '87 Error Handling at run-time:
  29. *
  30. *    SET ERRORSYS=S87
  31. *
  32. * To request Clipper 5.0 Error Handling at run-time:
  33. *
  34. *    SET ERRORSYS=5.0    (default)
  35. *
  36. * Written by:
  37. *
  38. *    Philip H. Schwartz
  39. *    Vertical Management Systems, Inc.
  40. *    POB 90243
  41. *    Gainesville, FL  32607
  42. *    Compuserve: 72537,3261
  43. *
  44. * Written on:
  45. *
  46. *    June 3, 1990     (for Palm Desert DevCon)
  47. *
  48. * Last updated on:
  49. *
  50. *    October 5, 1990  (for Orlando Devcon)
  51. *
  52. * Rights:
  53. *
  54. *    (c) 1990 Philip H. Schwartz
  55. *
  56. * Release:
  57. *
  58. *    Written for tutorial purposes and non-commercial distribution
  59. *    rights assigned to Clipper developer community.  May be distributed
  60. *    in this form without charge.  Commercial and publishing rights
  61. *    reserved.
  62. *
  63. * Warranty:
  64. *
  65. *    None.
  66. *
  67. * Comments:
  68. *
  69. *    Additional material (text and code) will be available
  70. *    in a forthcoming monograph on the Clipper 5.0 Error System
  71. *    and in a series of Nantucket News articles.
  72. *
  73. **************************************************************************/
  74.  
  75. LOCAL aErrors := ; 
  76.    { "? UnknownVar             Undef_error  -  Variable does not exist", ;
  77.      "USE missing.XYZ          Open_error   -  Open error", ;
  78.      "? 2 + '7'                Expr_error   -  Argument error", ;
  79.      "? SQRT('9')              Expr_error   -  Argument error", ;
  80.      "? VAL(9)                 Expr_error   -  Argument error", ;
  81.      "c:\this\does\not\exist   DB_error     -  Create error", ;
  82.      "Printer not ready        Print_error  -  Printer error", ;
  83.      "USE S87Demo.EXE          Misc_error   -  Corruption detected" }
  84.  
  85. LOCAL nErrType := 1
  86.  
  87. /***
  88. *    The following line calls the mapping routine that re-packages
  89. *    the Clipper 5.0 Error Object to the Summer '87 error UDF()s. 
  90. */
  91. S87ErrorSys()
  92.  
  93. /***
  94. *    This test program sets up several error conditions to
  95. *    demonstrate how the mapping routine works.  
  96. *
  97. *    Use the DOS SET ERRORSYS= command to select either Clipper 5.0
  98. *    or Summer '87 Error Handling conventions.
  99. */
  100.  
  101. CLS
  102. @ 1, 0 TO 14, 72
  103. @ 2, 1 SAY "ERROR HANDLING CONVENTIONS SELECTED: " + ;
  104.            IF( "S87" $ UPPER( GETE( "ERRORSYS" ) ), ;
  105.            "SUMMER '87", "CLIPPER 5.0" )
  106. @ 3, 0 SAY CHR(195) + REPLICATE( CHR(196), 71 ) + CHR(180)
  107. @ 4, 1 SAY ;
  108.    "Reason for error         S'87 UDF()      Clipper 5.0 Error Description"
  109. @ 5, 0 SAY CHR(195) + REPLICATE( CHR(196), 71 ) + CHR(180)
  110.  
  111. nErrType := ACHOICE( 6, 1, 13, 71, aErrors )
  112.  
  113. CLS
  114.  
  115. DO CASE
  116.  
  117. CASE nErrType == 1            // Error - Variable does not exist
  118.   ? unkn
  119.  
  120. CASE nErrType == 2             // Error - Open error
  121.   USE missing.XYZ
  122.  
  123. CASE nErrType == 3               // Error - Argument error
  124.   ? 2 + "7"
  125.  
  126. CASE nErrType == 4                // Error - Argument error
  127.   ? SQRT("9")
  128.  
  129. CASE nErrType == 5               // Error - Argument error
  130.   ? VAL(9)
  131.  
  132. CASE nErrType == 6               // Error - Create error
  133.   SET ALTERNATE TO c:\this\does\not\exist
  134.   SET ALTERNATE ON
  135.   SET ALTERNATE OFF
  136.   SET ALTERNATE TO
  137.      
  138. CASE nErrType == 7                 // Error - Printer error
  139.   ? "Please turn your printer OFF or set it OFFLINE"
  140.   ? "Press SPACE BAR when this is done"
  141.   INKEY(0)
  142.   EJECT
  143.  
  144. CASE nErrType == 8                // Error - Corruption detected
  145.   USE S87Demo.EXE            // Trying to open the EXE file as
  146.                       // a DBF should do it!
  147. ENDCASE
  148.  
  149. RETURN
  150. /*eof*/
  151.